using HKB.Common;
using HKB.Data.Dal;
using HKB.Data.Model;
using System;
using System.Collections.Generic;
using System.Data;
namespace HKB.Data.Bll
{
	public class StockInfoOrder
	{
		private readonly HKB.Data.Dal.StockInfoOrder dal = new HKB.Data.Dal.StockInfoOrder();
		public int GetMaxId()
		{
			return this.dal.GetMaxId();
		}
		public bool Exists(int InfoOrderID)
		{
			return this.dal.Exists(InfoOrderID);
		}
		public int Add(HKB.Data.Model.StockInfoOrder model)
		{
			return this.dal.Add(model);
		}
		public int AddTransaction(HKB.Data.Model.StockInfoOrder model, Conn conn)
		{
			return this.dal.AddTransaction(model, conn);
		}
		public bool UpdateTransaction(HKB.Data.Model.StockInfoOrder model, Conn conn)
		{
			return this.dal.UpdateTransaction(model, conn);
		}
		public bool Update(HKB.Data.Model.StockInfoOrder model)
		{
			return this.dal.Update(model);
		}
		public bool Delete(int InfoOrderID)
		{
			return this.dal.Delete(InfoOrderID);
		}
		public bool DeleteList(string InfoOrderIDlist)
		{
			return this.dal.DeleteList(InfoOrderIDlist);
		}
		public HKB.Data.Model.StockInfoOrder GetModel(int InfoOrderID)
		{
			return this.dal.GetModel(InfoOrderID);
		}
		public HKB.Data.Model.StockInfoOrder GetModelByCache(int InfoOrderID)
		{
			string cacheKey = "StockInfoOrderModel-" + InfoOrderID;
			object obj = DataCache.GetCache(cacheKey);
			if (obj == null)
			{
				try
				{
					obj = this.dal.GetModel(InfoOrderID);
					if (obj != null)
					{
						int configInt = ConfigHelper.GetConfigInt("ModelCache");
						DataCache.SetCache(cacheKey, obj, System.DateTime.Now.AddMinutes((double)configInt), System.TimeSpan.Zero);
					}
				}
				catch
				{
				}
			}
			return (HKB.Data.Model.StockInfoOrder)obj;
		}
		public DataSet GetList(string strWhere)
		{
			return this.dal.GetList(strWhere);
		}
		public DataSet GetList(int Top, string strWhere, string filedOrder)
		{
			return this.dal.GetList(Top, strWhere, filedOrder);
		}
		public System.Collections.Generic.List<HKB.Data.Model.StockInfoOrder> GetModelList(string strWhere)
		{
			DataSet list = this.dal.GetList(strWhere);
			return this.DataTableToList(list.Tables[0]);
		}
		public System.Collections.Generic.List<HKB.Data.Model.StockInfoOrder> DataTableToList(DataTable dt)
		{
			System.Collections.Generic.List<HKB.Data.Model.StockInfoOrder> list = new System.Collections.Generic.List<HKB.Data.Model.StockInfoOrder>();
			int count = dt.Rows.Count;
			if (count > 0)
			{
				for (int i = 0; i < count; i++)
				{
					HKB.Data.Model.StockInfoOrder stockInfoOrder = this.dal.DataRowToModel(dt.Rows[i]);
					if (stockInfoOrder != null)
					{
						list.Add(stockInfoOrder);
					}
				}
			}
			return list;
		}
		public DataSet GetAllList()
		{
			return this.GetList("");
		}
		public int GetRecordCount(string strWhere)
		{
			return this.dal.GetRecordCount(strWhere);
		}
		public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
		{
			return this.dal.GetListByPage(strWhere, orderby, startIndex, endIndex);
		}
		public DataTable GetStockInfoOrderByStockOrderID(int StockOrderID)
		{
			return this.dal.GetStockInfoOrderByStockOrderID(StockOrderID).Tables[0];
		}
		public string GetStockStatusStr(object obj)
		{
			string result = "";
			if (obj != null)
			{
				if (obj.ToString() == "0")
				{
					result = "未入库";
				}
				else
				{
					if (obj.ToString() == "1")
					{
						result = "已入库";
					}
					else
					{
						if (obj.ToString() == "2")
						{
							result = "未出库";
						}
						else
						{
							if (obj.ToString() == "3")
							{
								result = "已出库";
							}
						}
					}
				}
			}
			return result;
		}
		public string GetStockStatusStrMark(object value)
		{
			string result = value.ToString();
			if (value.ToString() == "1" || value.ToString() == "3")
			{
				result = "<span style='color:Green; font-size:12px;'>√</span>";
			}
			else
			{
				if (value.ToString() == "0" || value.ToString() == "2")
				{
					result = "<span style='color:Red; font-size:12px;'>×</span>";
				}
			}
			return result;
		}
		public DataTable GetStockOrderInfoItemListBySqlWhere(string strSQLWhere)
		{
			return this.dal.GetStockOrderInfoItemListBySqlWhere(strSQLWhere);
		}
		public int GetStockOrderInfoItemListRecordCount(string strSQLWhere)
		{
			return this.dal.GetStockOrderInfoItemListRecordCount(strSQLWhere);
		}
		public DataTable GetStockOrderInfoItemListPage(string strSQLWhere, string OrderBy, int startIndex, int endIndex)
		{
			return this.dal.GetStockOrderInfoItemListPage(strSQLWhere, OrderBy, startIndex, endIndex);
		}
		public DataTable GetListInfoItemProductByInfoOrderID(int infoOrderID)
		{
			return this.dal.GetListInfoItemProductByInfoOrderID(infoOrderID);
		}
		public DataTable GetListInfoItemProduct(string strSQLWhere)
		{
			return this.dal.GetListInfoItemProduct(strSQLWhere);
		}
		public int GetListInfoItemProductRecordCount(string strSQLWhere)
		{
			return this.dal.GetListInfoItemProductRecordCount(strSQLWhere);
		}
		public DataTable GetListInfoItemProductPage(string strSQLWhere, string OrderBy, int startIndex, int endIndex)
		{
			return this.dal.GetListInfoItemProductPage(strSQLWhere, OrderBy, startIndex, endIndex);
		}
	}
}
